home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / grabboxb.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  2.2 KB  |  76 lines

  1. ;void  grab_box_b(box,top_x,top_y,width,depth,color);
  2. ;  unsigned char  *box,top_x,top_y,width,depth,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_page:byte
  6.  
  7. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  8.     ASSUME CS:_TEXT
  9.     PUBLIC _grab_box_b
  10. _grab_box_b proc near
  11.     cld            ;set direction flag
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    mov  bh,_video_page    ;get _video_page
  21.     cmp  _memory_model,2    ;data near or far?
  22.     jb   L0            ;jump if near
  23.     les  di,dword ptr[bp+4] ;ES:DI pts to byte array
  24.     add  bp,2        ;inc BP since dword ptr
  25.     jmp  short L00        ;jump ahead
  26. L0:    mov  ax,ds        ;shift DS to ES
  27.     mov  es,ax        ;
  28.     mov  di,[bp+4]        ;
  29. L00:    mov  dl,[bp+6]        ;topleft column in DL
  30.     dec  dl            ;count from 0
  31.     mov  dh,[bp+8]        ;topleft row in DH
  32.     dec  dh            ;count from 0
  33.     mov  al,[bp+10]        ;width in AL
  34.     mov  ah,[bp+12]        ;depth in AH
  35.     mov  bl,[bp+14]        ;fill attribute in BL
  36.     mov  bp,ax        ;copy in BP
  37.     sub  cx,cx        ;clear CX
  38.     mov  cl,al        ;copy width into CX
  39.     mov  si,cx        ;move to SI as counter
  40.     mov  ah,2        ;function to set cursor
  41.     int  10h        ;set the cursor
  42.     push dx            ;save start-of-row pos
  43. L1:    mov  ah,8        ;func to read char-attri
  44.     int  10h        ;read the char and attri
  45.     stosw            ;write to the save area
  46.     mov  ah,9        ;func to write char-attri
  47.     mov  al,32        ;use space char for fill
  48.     mov  cx,1        ;number of chars to write
  49.     int  10h        ;write the fill character
  50.     dec  si            ;decrement width counter
  51.     jz   L3            ;to next row if last col
  52.     inc  dl            ;incre cursor col
  53. L2:    mov  ah,2        ;function to set cursor
  54.     int  10h        ;reset the cursor
  55.     jmp  short L1        ;go do next character
  56. L3:    pop  dx            ;new row: get old pos
  57.     mov  cx,bp        ;width-depth to CX
  58.     dec  ch            ;decre depth counter
  59.     jz   L4            ;quit if finished
  60.     mov  bp,cx        ;resave depth-width
  61.     sub  ch,ch        ;CX = width
  62.     mov  si,cx        ;transfer to SI as ctr
  63.     inc  dh            ;increase row number
  64.     push dx            ;save for next time
  65.     jmp  short L2        ;go set new cursor pos
  66. L4:    pop  si            ;
  67.     pop  di            ;
  68.     pop  bp            ;
  69.     cmp  _memory_model,0    ;quit
  70.     jle  quit        ;
  71.     db   0CBh        ;RET far
  72. quit:    ret            ;RET near
  73. _grab_box_b endp
  74. _TEXT    ENDS
  75.     END
  76.